package com.cmc.cloud.cmclink.doc.util;

import com.cmc.cloud.cmclink.doc.entity.BlnoCntrDO;
import org.springframework.stereotype.Component;

/**
 * @Description: 获取oog转换信息
 * @Author: lzp
 * @Date: 2025/11/7 10:47
 */
@Component
public class OogUtil {

    /**
     * 生成OOG信息
     *
     * @param blnoCntrDO 箱型参数
     * @return oog
     */
    public String buildOog(BlnoCntrDO blnoCntrDO) {
        Integer overForward = blnoCntrDO.getOverForward();
        boolean of = (overForward == null || overForward == 0);
        Integer overAfter = blnoCntrDO.getOverAfter();
        boolean oa = (overAfter == null || overAfter == 0);
        Integer overLeft = blnoCntrDO.getOverLeft();
        boolean ol = (overLeft == null || overLeft == 0);
        Integer overRight = blnoCntrDO.getOverRight();
        boolean or = (overRight == null || overRight == 0);
        Integer overHeight = blnoCntrDO.getOverHeight();
        boolean oh = (overHeight == null || overHeight == 0);
        String sizeType = blnoCntrDO.getCntrSize() + blnoCntrDO.getCntrType();
        String oog = "";
        switch (sizeType) {
            case "20FR":
            case "40FR":
                if (of || oa) {
                    oog = "EX1";
                    break;
                }
                boolean check1 = (ol || or) && !of && !oa && !oh;
                if (check1) {
                    oog = "EX2";
                    break;
                }
                boolean check2 = oh && !of && !oa && !ol && !or;
                if (check2) {
                    oog = "EX3";
                    break;
                }
                boolean check3 = oh && (ol || or);
                if (check3) {
                    oog = "EX4";
                    break;
                }
            case "20OT":
            case "40OT":
                if (oh) {
                    oog = "EX1";
                }
                break;
            default:
                oog = "";
        }
        return oog;
    }
}
